/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Test;

import com.bionic.CES.DAO.IUserDAO;
import com.bionic.CES.beans.User;
import com.bionic.CES.connections.DAOFactory;
import java.sql.SQLException;
import java.util.*;


/**
 *
 * @author Jarik
 */
public class Runner {
    //public static void main (String[] args){
    public List<User> run(User user){
    DAOFactory factory = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
    IUserDAO userDAO=factory.getUserDAO();
    
  //  User user = new User();
//   user.setName("Iaroslav");
//   user.setSurName("Kovalenko");
//    user.setEmail("xXx@ukr.net");
 //   user.setPassword("root");
//    user.setAdress("Ukraine");
//    user.setTelephone("063");
//    user.setStatus("ADMIN");
 //   user.setUserid(id);
    List<User> result = new ArrayList ();
        try {
            //userDAO.add(user);
            //System.out.println (userDAO.findByDynamicSelect(user));
            result = userDAO.findByDynamicSelect(user);
           
           // System.out.println ("User found succesfully");
        } catch (SQLException ex) {
            System.out.println ("Exception occured during adding new user ");
            ex.printStackTrace();
        }
         return result;
//        user.setUserid(2);
//        user.setAdress("Minsk");
//        try {
//            userDAO.update(user);
//            System.out.println ("User updated succesfully");
//        } catch (SQLException ex) {
//            System.out.println ("Exception occured during updating current user ");
//            ex.printStackTrace();
//        }
//     try {
//            userDAO.deleteById(user.getUserid());
//            System.out.println ("User deleted succesfully");
//        } catch (SQLException ex) {
//            System.out.println ("Exception occured during deleting current user ");
//            ex.printStackTrace();
//        }
        
    }
    
}
